package com.xiaoshuidi.cloud.module.iot.service.impl;

import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.xiaoshuidi.cloud.module.iot.api.device.vo.AmmeterInfoResModel;
import com.xiaoshuidi.cloud.module.iot.api.device.vo.WaterMeterCommonResponseModel;
import com.xiaoshuidi.cloud.module.iot.controller.admin.doorlock.vo.DeviceGetDailyPowerResModel;
import com.xiaoshuidi.cloud.module.iot.controller.admin.doorlock.vo.OperateThirdDeviceRequestModel;
import com.xiaoshuidi.cloud.module.iot.controller.admin.doorlock.vo.OperateThirdDeviceResponseModel;
import com.xiaoshuidi.cloud.module.iot.controller.admin.doorlock.vo.PullThirdDeviceRequestModel;
import com.xiaoshuidi.cloud.module.iot.dal.model.AccessTokenRequestModel;
import com.xiaoshuidi.cloud.module.iot.dal.model.AccessTokenResponseModel;
import com.xiaoshuidi.cloud.module.iot.dal.pojo.TbDeviceDo;
import com.xiaoshuidi.cloud.module.iot.enums.BrandEnum;
import com.xiaoshuidi.cloud.module.iot.enums.DeviceTypeEnum;
import com.xiaoshuidi.cloud.module.iot.enums.PasswordStatusEnum;
import com.xiaoshuidi.cloud.module.iot.enums.TianchengContants;
import com.xiaoshuidi.cloud.module.iot.service.AbstractThirdInstanceService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;

/**
 * 所有第三方交互唯一编码为imei，deviceId作废
 */
@Service
public class TianchengInstanceServiceImpl extends AbstractThirdInstanceService implements InitializingBean {

    private final static Logger LOGGER = LoggerFactory.getLogger(TianchengInstanceServiceImpl.class);

    @Value("${tiancheng.token}")
    private String token;

    @Value("${tiancheng.url}")
    private String url;

    @Override
    public String getBrand() {
        return BrandEnum.TIANCHENG.getBrand();
    }

    @Override
    public AccessTokenResponseModel getAccessToken(AccessTokenRequestModel accessTokenRequestModel) throws Exception {
        //天诚的access_token为固定值，直接配置进我们的配置文件中，取出来就好
        AccessTokenResponseModel accessTokenResponseModel = new AccessTokenResponseModel();
        accessTokenResponseModel.setAccessToken(token);
        return accessTokenResponseModel;
    }

    /**
     * 获取门锁设备列表
     *
     * @param pullThirdDeviceRequestModel 拉取请求
     * @return
     * @throws Exception
     */
    @Override
    public List<TbDeviceDo> getDevice(PullThirdDeviceRequestModel pullThirdDeviceRequestModel) throws Exception {
        List<TbDeviceDo> tbDeviceDoList = Lists.newArrayList();
        geLockDevice(tbDeviceDoList);
        LOGGER.info("天诚-拉取设备,设备数量:{}", tbDeviceDoList.size());
        return tbDeviceDoList;
    }

    /**
     * 拉取设备列表，目的为了将此账号下的所有设备落库 sdiot.tb_device
     *
     * @param tbDeviceDoList
     * @throws Exception
     */
    private void geLockDevice(List<TbDeviceDo> tbDeviceDoList) throws Exception {
        HashMap<String, String> header = buildTianchengReqHeader();
        try {
            HashMap params = new HashMap();
            params.put("pageSize", TianchengContants.BATCH_COUNT);
            params.put("pageNum", 1);
            LOGGER.info("天诚门锁-拉取设备，请求url:{},请求头:{},请求参数:{}", url + "lock", header, params);
            String result = HttpRequest.get(url + "lock").form(params).header("token",token).execute().body();
            LOGGER.info("天诚门锁-拉取设备,返回结果:{}", result);
            if (StringUtils.isNotBlank(result)) {
                JSONArray allDataArray = new JSONArray();
                JSONObject resultJson = JSONObject.parseObject(result);
                if (resultJson.getString("code").equals(TianchengContants.SUCCESS_CODE)) {
                    //获取门锁设备总页数
                    Integer forCount = resultJson.getJSONObject("data").getInteger("pageTotal");
                    JSONArray jsonArray = resultJson.getJSONObject("data").getJSONArray("list");
                    allDataArray.addAll(jsonArray);
                    if (jsonArray.size() == TianchengContants.BATCH_COUNT) {
                        //获取所有门锁设备
                        for (int i = 2; i <= forCount; i++) {
                            params.clear();
                            params.put("pageSize", 1000);
                            params.put("page", i);
                            HashMap<String, String> headerMap = buildTianchengReqHeader();
                            LOGGER.info("天诚-拉取设备第{}页，请求url:{},请求头:{},请求参数:{}", i, url + "lock", header, params);
                            result = HttpRequest.get(url + "lock").form(params).header("token",token).execute().body();
                            LOGGER.info("天诚-拉取设备第{}页,返回结果:{}", i, result);
                            resultJson = JSONObject.parseObject(result);
                            if (resultJson.getString("code").equals(TianchengContants.SUCCESS_CODE)) {
                                JSONArray jsonArrayP = resultJson.getJSONObject("data").getJSONArray("list");
                                allDataArray.addAll(jsonArrayP);
                            }
                        }
                    }

                    for (Iterator<Object> dataIterator = allDataArray.iterator(); dataIterator.hasNext(); ) {
                        JSONObject dataJson = (JSONObject) dataIterator.next();
                        TbDeviceDo tbDeviceDo = new TbDeviceDo();
                        //imei是设备唯一标识
                        String imei = dataJson.getString("imei");
                        String deviceId = dataJson.getString("id");
                        tbDeviceDo.setDeviceThirdNo(imei);
                        //deviceId在天诚可能会变，作为deviceName
                        tbDeviceDo.setDeviceName(deviceId);
                        //设备类型
                        tbDeviceDo.setDeviceType(DeviceTypeEnum.DOORLOCK.getCode());
                        //第三方返回的设备电量
                        Integer batteryLevel = dataJson.getInteger("batteryLevel");
                        tbDeviceDo.setBatteryLevel(Double.valueOf(String.valueOf(batteryLevel)));
                        //创建人， saas系统都为10001，固定值
                        //tbDeviceDo.setCreateUser(10001);
                        //第三方返回的设备状态
                        Integer deviceStatus = dataJson.getInteger("deviceStatus");
                        // 0：正常；1：不正常；2：未激活；3：离线
                        switch (deviceStatus) {
                            case 3:
                                //sdiot.tb_device表中有说明，0为离线，1为在线
                                tbDeviceDo.setOnlineStatus(0);
                                break;
                            default:
                                tbDeviceDo.setOnlineStatus(1);
                                break;
                        }
                        //第三方返回的设备型号
                        String deviceModel = dataJson.getString("deviceModel");
                        tbDeviceDo.setDeviceModel(deviceModel);
                        tbDeviceDo.setReportTime(LocalDateTime.now());
                        tbDeviceDo.setCreateTime(LocalDateTime.now());
                        tbDeviceDoList.add(tbDeviceDo);
                    }
                }
            }
        } catch (Exception e) {
            LOGGER.info("天诚-拉取设备报错信息:{}", e.getMessage());
            throw e;
        }
    }

    @Override
    public List<TbDeviceDo> initializeDeviceInfo(List<TbDeviceDo> thirdDeviceList, PullThirdDeviceRequestModel pullThirdDeviceRequestModel) {
        return null;
    }

    @Override
    public OperateThirdDeviceResponseModel addDoorLockPassword(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        OperateThirdDeviceResponseModel operateThirdDeviceResponseModel = null;
        // 1 : 普通密码   6 : 离线密码
        switch (operateThirdDeviceRequestModel.getPasswordType()) {
            case "1":
                //permanentFlag永久标记（1：永久密码；2：临时密码）
                operateThirdDeviceResponseModel = addDoorOnlineLockPassword(operateThirdDeviceRequestModel, 1);
                break;
            case "6":
                operateThirdDeviceResponseModel = addDoorOfflineLockPassword(operateThirdDeviceRequestModel);
                break;
        }
        return operateThirdDeviceResponseModel;
    }

    /**
     * 下发在线密码
     *
     * @param operateThirdDeviceRequestModel
     * @return
     * @throws Exception
     */
    private OperateThirdDeviceResponseModel addDoorOnlineLockPassword(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel, Integer permanentFlag) throws Exception {
        HashMap<String, String> header = buildTianchengReqHeader();
        JSONObject params = new JSONObject();
        String deviceThirdNo = operateThirdDeviceRequestModel.getDeviceThirdNo();

        String deviceName = operateThirdDeviceRequestModel.getDeviceName();
        params.put("deviceLockId", deviceName);
        //根据2023-07-13 10:15:00 与天诚会议确定,所有交互以 imei 作为唯一标识
        params.put("imei", deviceThirdNo);
        //密码类型（1:指纹:2:密码;3:卡 ;11: 人脸）
        params.put("passwordType", "2");
        //密码权限(1:管理员 2:普通用户)
        params.put("passwordAuth", 2);
        //永久标记（1：永久密码；2：临时密码）
        params.put("permanentFlag", permanentFlag);
        //密码值
        params.put("password", operateThirdDeviceRequestModel.getPasswordContent());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //密码期限 - 开始时间
        Long passwordStartTime = operateThirdDeviceRequestModel.getPasswordStartTime();
        //密码期限 - 结束时间
        Long passwordEndTime = operateThirdDeviceRequestModel.getPasswordEndTime();
        if (null != passwordStartTime) {
            Date startDate = new Date(passwordStartTime);
            String startString = sdf.format(startDate);
            params.put("startTime", startString);
        }
        if (null != passwordEndTime) {
            Date endDate = new Date(passwordEndTime);
            String endString = sdf.format(endDate);
            params.put("endTime", endString);
        }
        //密码名称，第三方要求，与我们关系不大
        params.put("passwordName", operateThirdDeviceRequestModel.getUserName());
        String paramStr = params.toJSONString();
        LOGGER.info("天诚-addPassword，请求url:{},请求头:{},请求参数:{}", url + "lock/password", header, paramStr);
        String result = HttpRequest.post(url + "lock/password").body(paramStr).header("token",token).header("Content-Type", "application/json").execute().body();
        LOGGER.info("天诚-addPassword,返回结果:{}", result);
        OperateThirdDeviceResponseModel operateThirdDeviceResponseModel = new OperateThirdDeviceResponseModel();
        if (StringUtils.isNotBlank(result)) {
            JSONObject resultJson = JSONObject.parseObject(result);
            if (resultJson.getString("code").equals(TianchengContants.SUCCESS_CODE)) {
                JSONObject resultData = resultJson.getJSONObject("data");
                //返回结果-操作结果为成功，默认为失败
                operateThirdDeviceResponseModel.setOperateResult(true);
                //密码状态，第三方厂商为异步返回,我们操作下发密码以后,调用第三方接口；此时并不指导第三方那边是否真的成功,所以我们的密码状态为executing中,指导第三方回调通知我们此密码是否生效，再进行密码状态最终修改
                operateThirdDeviceResponseModel.setPasswordStatus(PasswordStatusEnum.EXECUTING.getCode());
                //第三方密码Id,一把门锁可以有很多的密码,我们一般根据第三方密码id来确定这把锁的唯一密码；有的厂商密码Id为我们根据对方规则来自定义,有的像天诚门锁一样由第三方返回
                operateThirdDeviceResponseModel.setThirdPassId(String.valueOf(resultData.getLong("id")));
                //密码值
                operateThirdDeviceResponseModel.setPasswordContent(operateThirdDeviceRequestModel.getPasswordContent());
            } else {
                operateThirdDeviceResponseModel.setOperateResult(false);
                operateThirdDeviceResponseModel.setOperateMessage(resultJson.getString("message"));
            }
        }
        return operateThirdDeviceResponseModel;
    }

    /**
     * 下发离线密码
     *
     * @param operateThirdDeviceRequestModel
     * @return
     * @throws Exception
     */
    private OperateThirdDeviceResponseModel addDoorOfflineLockPassword(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        HashMap<String, String> header = buildTianchengReqHeader();
        JSONObject params = new JSONObject();
        String deviceThirdNo = operateThirdDeviceRequestModel.getDeviceThirdNo();
        params.put("imei", deviceThirdNo);
        LOGGER.info("天诚-addOfflinePassword，请求url:{},请求头:{},请求参数:{}", url + "lock/password/offline", header, params.toJSONString());
        String result = HttpRequest.get(url + "lock/password/offline").body(params.toJSONString()).header("token",token).header("Content-Type", "application/json").execute().body();
        LOGGER.info("天诚-addOfflinePassword,返回结果:{}", result);
        OperateThirdDeviceResponseModel operateThirdDeviceResponseModel = new OperateThirdDeviceResponseModel();
        if (StringUtils.isNotBlank(result)) {
            JSONObject resultJson = JSONObject.parseObject(result);
            if (resultJson.getString("code").equals(TianchengContants.SUCCESS_CODE)) {
                String resultData = resultJson.getString("data");
                operateThirdDeviceResponseModel.setOperateResult(true);
                operateThirdDeviceResponseModel.setPasswordStatus(PasswordStatusEnum.EXECUTING.getCode());
                operateThirdDeviceResponseModel.setPasswordContent(resultData);
            } else {
                operateThirdDeviceResponseModel.setOperateResult(false);
                operateThirdDeviceResponseModel.setOperateMessage(resultJson.getString("message"));
            }
        }
        return operateThirdDeviceResponseModel;
    }

    @Override
    public OperateThirdDeviceResponseModel getDynamicDoorLockPassword(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        OperateThirdDeviceResponseModel operateThirdDeviceResponseModel = addDoorOnlineLockPassword(operateThirdDeviceRequestModel, 2);
        return operateThirdDeviceResponseModel;
    }

    @Override
    public AmmeterInfoResModel refreshAmmeterInfo(TbDeviceDo tbDeviceDo, OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        return null;
    }

    @Override
    public List<DeviceGetDailyPowerResModel> getDailyPower(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) {
        return null;
    }

    @Override
    public OperateThirdDeviceResponseModel updateDoorLockPassword(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        //操作类型（2：更新密码；4：冻结；5：解冻）
        OperateThirdDeviceResponseModel operateThirdDeviceResponseModel = upOrFreezeOrUnFreezePwd(operateThirdDeviceRequestModel, "2");
        return operateThirdDeviceResponseModel;
    }

    @Override
    public OperateThirdDeviceResponseModel frozenDoorLockPassword(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        //操作类型（2：更新密码；4：冻结；5：解冻）
        OperateThirdDeviceResponseModel operateThirdDeviceResponseModel = upOrFreezeOrUnFreezePwd(operateThirdDeviceRequestModel, "4");
        return operateThirdDeviceResponseModel;
    }

    @Override
    public OperateThirdDeviceResponseModel unfrozenDoorLockPassword(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        //操作类型（2：更新密码；4：冻结；5：解冻）
        OperateThirdDeviceResponseModel operateThirdDeviceResponseModel = upOrFreezeOrUnFreezePwd(operateThirdDeviceRequestModel, "5");
        return operateThirdDeviceResponseModel;
    }

    /**
     * 修改密码, 天诚的密码只支持时间的修改,不支持密码值修改
     *
     * @param operateThirdDeviceRequestModel
     * @param optType
     * @return
     * @throws Exception
     */
    private OperateThirdDeviceResponseModel upOrFreezeOrUnFreezePwd(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel, String optType) throws Exception {
        HashMap<String, String> header = buildTianchengReqHeader();
        header.put("Content-Type", "application/json");
        JSONObject params = new JSONObject();
        params.put("id", operateThirdDeviceRequestModel.getPasswordId());
        // 2 - 普通密码修改
        if ("2".equals(optType)) {
            Long passwordStartTime = operateThirdDeviceRequestModel.getPasswordStartTime();
            Long passwordEndTime = operateThirdDeviceRequestModel.getPasswordEndTime();
            Date startTime = new Date(passwordStartTime);
            Date endTime = new Date(passwordEndTime);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            params.put("startTime", sdf.format(startTime));
            params.put("endTime", sdf.format(endTime));
        }
        //optType - 告知天诚密码操作类型（2：更新密码；4：冻结；5：解冻）
        params.put("operationType", optType);
        String paramJson = params.toJSONString();
        LOGGER.info("天诚-updateDoorLockPassword，请求url:{},请求头:{},请求参数:{}", url + "lock/password", header, params.toJSONString());
        String result = HttpRequest.put(url + "lock/password").body(paramJson).header("token",token).header("Content-Type", "application/json").execute().body();
        LOGGER.info("天诚-updateDoorLockPassword,返回结果:{}", result);
        JSONObject resultJsonObject = JSONObject.parseObject(result);
        OperateThirdDeviceResponseModel operateThirdDeviceResponseModel = new OperateThirdDeviceResponseModel();
        if (TianchengContants.SUCCESS_CODE.equals(resultJsonObject.getString("code"))) {
            operateThirdDeviceResponseModel.setOperateResult(true);
            //请求天诚成功，将我们数据库中密码状态改为执行中-4；待callback服务模块接收到天诚回调成功信息再将密码状态改为生效/冻结/解冻状态
            operateThirdDeviceResponseModel.setPasswordStatus(4);
        } else {
            operateThirdDeviceResponseModel.setOperateResult(false);
            operateThirdDeviceResponseModel.setOperateMessage(resultJsonObject.getString("message"));
        }
        return operateThirdDeviceResponseModel;
    }

    @Override
    public OperateThirdDeviceResponseModel switchAmmeterOn(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        return null;
    }

    @Override
    public OperateThirdDeviceResponseModel switchAmmeterOff(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        return null;
    }

    /**
     * 删除密码
     *
     * @param operateThirdDeviceRequestModel
     * @return
     * @throws Exception
     */
    @Override
    public OperateThirdDeviceResponseModel deleteDoorLockPassword(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        TreeMap header = new TreeMap<>();
        header.put("token", token);
        header.put("Content-Type", "application/json");
        TreeMap params = new TreeMap<>();
        params.put("id", operateThirdDeviceRequestModel.getPasswordId());
        LOGGER.info("天诚门锁-删除在线密码，请求url:{},请求头:{},请求参数:{}", url + "lock/password", header, params);
        String result = HttpRequest.delete(url + "lock/password").body(JSONObject.toJSONString(params)).header("token",token).header("Content-Type", "application/json").execute().body();
        LOGGER.info("天诚门锁-删除在线密码,返回结果:{}", result);
        OperateThirdDeviceResponseModel operateThirdDeviceResponseModel = new OperateThirdDeviceResponseModel();
        if (StringUtils.isNotBlank(result)) {
            JSONObject resultJson = JSONObject.parseObject(result);
            if (TianchengContants.SUCCESS_CODE.equals(resultJson.getString("code"))) {
                operateThirdDeviceResponseModel.setOperateResult(true);
                //请求天诚成功，将我们数据库中密码状态改为执行中-4；待callback服务模块接收到天诚回调成功信息再将密码状态改为失效，此处删除为逻辑删除
                operateThirdDeviceResponseModel.setPasswordStatus(PasswordStatusEnum.EXPIRED.getCode());
                operateThirdDeviceResponseModel.setThirdPassId(operateThirdDeviceRequestModel.getPasswordId());
            } else {
                operateThirdDeviceResponseModel.setOperateResult(false);
                operateThirdDeviceResponseModel.setOperateMessage(resultJson.getString("message"));
            }
        }
        return operateThirdDeviceResponseModel;
    }

    @Override
    public WaterMeterCommonResponseModel refreshWatermeterInfo(WaterMeterCommonResponseModel waterMeterCommonResponseModel, OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        return null;
    }


    /**
     * 刷新门锁时候,获取设备信息
     *
     * @param operateThirdDeviceRequestModel
     * @return
     * @throws Exception
     */
    @Override
    public OperateThirdDeviceResponseModel getDoorLockStatus(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        HashMap<String, String> header = buildTianchengReqHeader();
        HashMap params = new HashMap();
        String deviceThirdNo = operateThirdDeviceRequestModel.getDeviceThirdNo();
        params.put("imei", deviceThirdNo);
        LOGGER.info("天诚门锁-获取设备信息，请求url:{},请求头:{},请求参数:{}", url + "lock", header, params);
        String result = HttpRequest.get(url + "lock").body(JSONObject.toJSONString(params)).header("token",token).header("Content-Type", "application/json").execute().body();
        LOGGER.info("天诚门锁-获取设备信息,返回结果:{}", result);
        OperateThirdDeviceResponseModel operateThirdDeviceResponseModel = new OperateThirdDeviceResponseModel();
        if (StringUtils.isNotBlank(result)) {
            JSONObject resultJson = JSONObject.parseObject(result);
            if (TianchengContants.SUCCESS_CODE.equals(resultJson.getString("code"))) {
                JSONArray jsonArray = resultJson.getJSONObject("data").getJSONArray("list");
                //根据imei获取此设备信息, 返回数据格式与拉取设备相同；list中只返回需要查询的设备
                if (jsonArray.size() > 0) {
                    JSONObject jsonObject = (JSONObject) jsonArray.get(0);
                    Integer batteryPercentage = jsonObject.getInteger("batteryLevel");
                    operateThirdDeviceResponseModel.setBatteryLevel(Double.valueOf(String.valueOf(batteryPercentage)));
                    Integer deviceStatus = jsonObject.getInteger("deviceStatus");
                    // 0：正常；1：不正常；2：未激活；3：离线
                    switch (deviceStatus) {
                        case 3:
                            //在我们数据库中，onlineStatus 1为在线 0为离线状态； 此处我们只关心设备是在线还是离线，其余状态按在线处理
                            operateThirdDeviceResponseModel.setOnlineStatus(0);
                            break;
                        default:
                            operateThirdDeviceResponseModel.setOnlineStatus(1);
                            break;
                    }
                }
                operateThirdDeviceResponseModel.setOperateResult(true);
            } else {
                operateThirdDeviceResponseModel.setOperateResult(false);
                operateThirdDeviceResponseModel.setOperateMessage(resultJson.getString("errorinfo"));
            }
        }
        return operateThirdDeviceResponseModel;
    }

    @Override
    public OperateThirdDeviceResponseModel getOpenLockRecordes(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        return null;
    }

    @Override
    public OperateThirdDeviceResponseModel switchColdWaterMeterOff(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        return null;
    }

    @Override
    public OperateThirdDeviceResponseModel switchHotWaterMeterOff(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        return null;
    }

    @Override
    public OperateThirdDeviceResponseModel switchHotWaterMeterOn(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        return null;
    }

    @Override
    public OperateThirdDeviceResponseModel switchColdWaterMeterOn(OperateThirdDeviceRequestModel operateThirdDeviceRequestModel) throws Exception {
        return null;
    }

    private HashMap<String, String> buildTianchengReqHeader() {
        HashMap<String, String> header = Maps.newHashMap();
        header.put("token", token);
        header.put("Content-Type", "application/json");
        return header;
    }


    @Override
    public void afterPropertiesSet() {
        LOGGER.info("天诚门锁服务已注册");
    }
}
